<?php


namespace RedMVC\Form;

/**
 * File class
 *
 * @category    RedMVC
 * @package     Form
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class File{

    const FILE_NAME_ORIGINAL    = '_original_';
    const FILE_NAME_RANDOM      = '_random_';
    
    const FILE_SIZE_1MB         = 1048576;
    const FILE_SIZE_2MB         = 2097152;
    const FILE_SIZE_5MB         = 5242880;
    const FILE_SIZE_10MB        = 10485760;
    const FILE_SIZE_20MB        = 20971520;
    const FILE_SIZE_50MB        = 52428800;
    
    public $targetFolder;
    public $fileName;
    public $maxSize;
    public $allowedArray;
    
    public $maxFiles;
    public $maxSizeTotal;

    protected $_finalFile;

    public function __construct($targetFolder, $fileName=self::FILE_NAME_ORIGINAL, $maxSize=self::FILE_SIZE_1MB, $allowedArray=Array('jpg', 'gif', 'png')){
        $this->targetFolder = $targetFolder;
        $this->fileName     = $fileName;
        $this->maxSize      = $maxSize;
        $this->allowedArray = $allowedArray;
    }
    
    public function setMaxFiles($maxFiles){
        $this->maxFiles = $maxFiles;
        $this->maxSizeTotal = ($this->maxSize * $maxFiles);
        return $this;
    }

    public function setFinalFile($finalFile){
        $this->_finalFile = $finalFile;
        return $this;
    }

    public function getFinalFile(){
        return $this->_finalFile;
    }

}